package com.cat.dataStructure;

/**
 * @author 曲大人的喵
 * @description 、
 * @create 2025/10/2 21:58
 * @since JDK17
 */

public class Solution93 {
    public int minimumDifference(int[] nums, int k) {
        int ans = Integer.MAX_VALUE, n = nums.length;
        for (int i = 0; i < n; i++) {
            int x = nums[i];
            ans = Math.min(ans, Math.abs(x - k));
            for (int j = i - 1; j >= 0 && ((x | nums[j]) != nums[j]); j--) {
                x |= nums[j];
                ans = Math.min(ans, Math.abs(x - k));
            }
        }
        
        return ans;
    }
}
